<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="support.*, java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Provide degrees - Choose universities</title>
</head>
<body>
<%	String stateIndex = request.getParameter("stateIndex");
	session.setAttribute("stateIndex", stateIndex); 
	
	Integer sIndex = 0;

	if(stateIndex != null){
		sIndex = Integer.parseInt(stateIndex);
	}
	
	String path = config.getServletContext().getRealPath("universities.txt");
	support s = new support();
	Vector universities = s.getUniversities(path);

	Vector tuple = (Vector)universities.get(sIndex);
	String state = (String)tuple.get(0);%>
<center>
<h1><%=state %></h1>
Please choose or add your university:
</center>
<% 	Integer columncounter = 0;
	out.println("<br>");
	out.println("<table width=\"600\" border=\"2\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\">");

    Vector u = (Vector)tuple.get(1);
   	for(int j=0; j<u.size(); j++){
   		columncounter += 1;
   		if(columncounter == 1)
   			out.println("<tr>");
   		
   		out.println("<td>" + "<a href=\"http://localhost:8080/GraduateSchoolApp/provideDegreesChooseDiscipline.jsp?university=" + u.get(j) + "\">" + u.get(j) + "</a>" + "</td>");
   		
   		if (columncounter >= 3) {
   			out.println("</tr>");
   			columncounter = 0;
   		}
	} 
	out.println("</table>");
	out.println("<br>");%><br>
	<form method="GET" action="provideDegreesChooseDiscipline.jsp">
	<center>Other University: <input type ="text" size="60" name="university" />
	<input type="submit" value="Submit"/></center>
	</form>
</body>
</html>